#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : gtmsAutoTestProject 
@File    : food_list_interface.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/6/27 10:01 
@Describe:
"""
from fastapi import APIRouter
from FastApi.enum.food_type_enum.food_type_enum import FOOD_TYPE_ENUM
from FastApi.dto.pos.food.food_list_dto import FoodListDtoModel
from FastApi.server.pos.food.food_list_server import FoodListServer
from Comm.logUtils.logControl import LogHandler

logger = LogHandler().get_logger()
foodList_route = APIRouter()


@foodList_route.post("/list", name="获取下单菜品数据")
async def foodList(payload: FoodListDtoModel):
    logger.info('请求参数:[{}]'.format(payload))
    pos_food_api = FoodListServer(payload.brandCode, payload.environment)
    food_info = {"code": 200, "data": []}
    if payload.foodType == FOOD_TYPE_ENUM.BASE.value:
        food_info["data"].append(pos_food_api.get_base_food_data())
    elif payload.foodType == FOOD_TYPE_ENUM.SUIT.value:
        food_info["data"].append(pos_food_api.get_suit_food_data())
    elif payload.foodType == FOOD_TYPE_ENUM.TASTE.value:
        food_info["data"].append(pos_food_api.get_taste_food_data())
    else:
        error_info = {"code": 5000, "message": "请输入正确的请求参数!"}
        return error_info
    logger.info('接口响应:[{}]'.format(food_info))
    return food_info

